package com.dao.impl;

import com.dao.NewsDao;
import com.entity.News;
import com.mapper.NewsMapper;
import com.page.PageInfo;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("newsDao")//一般实现类不会直接生成默认对象名 而是使用 接口的默认对象名
public class NewsDaoImpl implements NewsDao {
    @Resource //autowired 会装配能够直接扫描到的对象  resource spring容器运行的时候才找到需要的对象  注入
    private NewsMapper newsMapper;
    @Override
    public List<News>  getAllNewss(){
        return newsMapper.selectByExample(null);
    }
    @Override
    public List<News> getNewsByPage(PageInfo pageInfo) {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("currPage",pageInfo.getCurrPage());
        map.put("pageSize",pageInfo.getPageSize());
        System.out.println("111");
        return newsMapper.getNewsByPage(map);
    }

    @Override
    public News getNewsByIdWithAnos(String nId) {
        return newsMapper.getNewsByIdWithAnos(nId);
    }

}
